#include <stdio.h>
#include <sqlite3.h>

int main() {
    sqlite3 *db;
    char *err_message = 0;

    // 打开数据库连接
    int rc = sqlite3_open("your_database_file.db", &db);

    if (rc != SQLITE_OK) {
        fprintf(stderr, "无法打开数据库: %s\n", sqlite3_errmsg(db));
        sqlite3_close(db);
        return 1;
    }

    // 查询数据
    const char *sql_query = "SELECT * FROM user";
    sqlite3_stmt *res;

    rc = sqlite3_prepare_v2(db, sql_query, -1, &res, 0);
    if (rc != SQLITE_OK) {
        fprintf(stderr, "无法执行查询: %s\n", sqlite3_errmsg(db));
    } else {
        while (sqlite3_step(res) == SQLITE_ROW) {
            // 获取数据
            int id = sqlite3_column_int(res, 0);
            const unsigned char *username = sqlite3_column_text(res, 1);
            const unsigned char *email = sqlite3_column_text(res, 2);

            // 打印数据
            printf("ID: %d, Username: %s, Email: %s\n", id, username, email);
        }
    }

    // 释放资源
    sqlite3_finalize(res);
    sqlite3_close(db);

    return 0;
}
